<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <search :config='searchConfig' @search='search' @getHeight='getHeight' />
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        :border='true'
        :resizable='true'
        :showOverflow='true'
        size='mini'
        :loading='loading'
        :height='pageHeight-seachHeight-90'
        :align='left'
        :columns='columns'
        :data='dataSource'
        :toolbar-config='tableToolbar'
       :checkbox-config="checkboxConfig"
        v-bind='vexConfig'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button v-has="'politicArea:add'" @click='handleAdd'>新增</a-button>
            <a-button v-has="'politicArea:delete'" @click='batchDel'>删除</a-button>
            <a-button v-has="'politicArea:synchronization'"  @click=''>同步</a-button>
            <a-button v-has="'politicArea:export'"  @click=''>导出</a-button>
          </div>
        </template>

        <template #detail='{ row,rowIndex }'>
          <a @click="handleDetail(row)">{{ row.provinceName }}</a>
        </template>
        <template #status='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>

        <template #action='{ row:record }'>
          <a v-has="'politicArea:update'" @click='handleEdit(record)'>编辑</a>
          <a-divider type='vertical' />
          <a v-has="'business:log'" href='javascript:;' @click='handleBusiness("行政区域",row)'>日志</a>
        </template>

        <template #pager>
          <vxe-pager
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :currentPage.sync='ipagination.current'
            :page-size.sync='ipagination.pageSize'
            :total='ipagination.total'
            :pageSizes='ipagination.pageSizeOptions'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>

    <business-log ref='businessLog'></business-log>
    <politic-area-modal ref='modalForm' @ok='modalFormOk'></politic-area-modal>
  </a-card>
</template>

<script>
import politicAreaModal from './modules/PoliticAreaModal.vue'
import { PageListMixin } from '@/mixins/PageListMixin'
import { getAction, postAction } from '@api/manage'

export default {
  name: 'politicArea',
  mixins: [PageListMixin],
  components: {
    politicAreaModal
  },
  data() {
    return {
      description: '行政区域',
      // 表头
      searchConfig: [
        {
          // label:'区域编号',
          type: 'input',
          name: 'provinceName',
          placeholder: '省',
        }, {
          // label:'区域名称',
          type: 'input',
          name: 'provinceCode',
          placeholder: '省编号'
        },
        {
          // label:'区域编号',
          type: 'input',
          name: 'cityName',
          placeholder: '市'
        }, {
          // label:'区域名称',
          type: 'input',
          name: 'cityCode',
          placeholder: '市编号'
        },
        {
          // label:'区域编号',
          type: 'input',
          name: 'districtName',
          placeholder: '区县'
        }, {
          // label:'区域名称',
          type: 'input',
          name: 'districtCode',
          placeholder: '区县编号'
        }, {
          // label:'区域编号',
          type: 'input',
          name: 'countryName',
          placeholder: '街道镇乡'
        }, {
          // label:'区域名称',
          type: 'input',
          name: 'countryCode',
          placeholder: '街道镇乡编号'
        }
      ],
      columns: [
        { type: 'checkbox', width: 60, fixed: 'left' },
        {
          title: '省',
          minWidth: 80,
          field: 'provinceName',
          // slots: { default: 'detail' }
        },
        {
          title: '省编号',
          minWidth: 80,
          field: 'provinceCode'
        },
        {
          title: '市',
          minWidth: 80,
          field: 'cityName'
        },
        {
          title: '市编号',
          minWidth: 80,
          field: 'cityCode'
        },
        {
          title: '区县',
          minWidth: 80,
          field: 'districtName'
        },
        {
          title: '区县编号',
          minWidth: 80,
          field: 'districtCode'
        },
        {
          title: '街道镇乡',
          minWidth: 80,
          field: 'countryName'
        },
        {
          title: '街道镇乡编号',
          minWidth: 100,
          field: 'countryCode'
        },
        {
          title: '创建人',
          align: 'left',
          minWidth:80,
          field: 'createName',
        },
        {
          title: '创建时间',
          align: 'left',
          minWidth:80,
          field: 'createTime',
        },
        {
          title: '更新人',
          align: 'left',
          minWidth:80,
          field: 'updateName',
        },
        {
          title: '更新时间',
          align: 'left',
          minWidth:80,
          field: 'updateTime',
        },
        {
          fixed: 'right',
          title: '操作',
          width: 120,
          minWidth: 80,
          slots: { default: 'action' }
        }
      ],
      url: {
        list: window._CONFIG['domianURL'] + '/org/cnRegion/findPageList',
        detail: window._CONFIG['domianURL'] + '/org/cnRegion/getInfo',
        edit: window._CONFIG['domianURL'] + '/mdsProduct/saveOrUpdateEntity',
        deleteBatch: window._CONFIG['domianURL'] + '/org/cnRegion/deleteBatch',
        delete: window._CONFIG['domianURL'] + '/org/cnRegion/delete',
        exportXlsUrl: window._CONFIG['domianTpmURL'] + 'budget/tpmBudgetFee/exportXls'
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {}
}
</script>

<style scoped>
@import '~@assets/less/common.less';
</style>